package main

import (
	"flag"
	"fmt"
	"google.golang.org/grpc"
	"log"
	"mxshop_srvs/user_srv/handler"
	"mxshop_srvs/user_srv/proto"
	"net"
)

func main() {
	ip := flag.String("ip", "127.0.0.1", "请输入ip地址")
	port := flag.Int("port", 50051, "请输入端口号")
	fmt.Println(*ip)
	fmt.Println(*port)
	// 创建监听地址
	lis, err := net.Listen("tcp", fmt.Sprintf("%s:%d", *ip, *port))
	if err != nil {
		log.Fatalf("Failed to listen: %v", err)
	}
	// 创建 gRPC 服务器
	server := grpc.NewServer()
	// 注册 Hello 服务
	proto.RegisterUserServer(server, &handler.UserService{})
	// 启动服务
	if err := server.Serve(lis); err != nil {
		log.Fatalf("Failed to serve: %v", err)
	}
}
